package zjc.案例练习;

import java.util.Scanner;

public class 判段素数 {
    public static void main(String[] args) {
        Scanner sr = new Scanner(System.in);
        System.out.println("输入最小值");
        int l=sr.nextInt();
        System.out.println("输入最大值");
        int r=sr.nextInt();
        for (int i = l; i <=r ; i++) {
            if(p(i)==1){
                System.out.print(i+" ");
            }
        }
    }
    public  static int p(int n){
        if(n==1){
            return -1;
        }else if(n==2){
            return 1;
        }else {
            for (int i = 2; i < n/2 ; i++) {
                if(n%i==0){
                    return -1;
                }
            }
            return 1;
        }
    }
}
